<?php

namespace App\Rules;

use Closure;
use Illuminate\Contracts\Validation\ValidationRule;

class PhoneRule implements ValidationRule {
    /**
     * Run the validation rule.  laravel9 10
     *
     * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail
     */
    public function validate(string $attribute, mixed $value, Closure $fail): void {
        //'/^1[34578]\d{9}$/'
        if(!preg_match("/^1\d{10}$/",$value)){
            $fail('手机格式不正确');
        }

    }
}
